#!/bin/bash

help() {
  echo "Usage:"
  echo "  zmachine disk usage [options...]"
  echo "    -t, --total   Get total disk, unit: G"
  echo "    -u, --used    Get used disk, unit: G"
  echo "    -p, --percent Get used percent"
}

# disk_percent() {
#   local VOLUME=$(zmachine disk volume)
#   disk_usage=`df -h | grep $VOLUME | awk -F '[ %]+' '{print $5}'`
#   echo -e "${disk_usage}"
# }

# disk_used() {
#   local VOLUME=$(zmachine disk volume)
#   disk_usage=`df -h | grep $VOLUME | awk -F '[ %]+' '{print $3}'`
#   echo -e "${disk_usage}"
# }

# disk_total() {
#   local VOLUME=$(zmachine disk volume)
#   disk_usage=`df -h | grep $VOLUME | awk -F '[ %]+' '{print $2}'`
#   echo -e "${disk_usage}"
# }

core() {
  if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
    help
    exit 0
  fi

  local option=$1
  case $option in
    "")
      os::disk_usage percent
      ;;
    -u | --used)
      os::disk_usage used
      ;;
    -t | --total)
      os::disk_usage total
      ;;
    -p | --percent)
      os::disk_usage percent
      ;;
    *)
      help
      ;;
  esac
}

run() {
  core $@
}

run $@
